package com.aliyun.messagemgt.repository;

import com.aliyun.messagemgt.converter.SysUserInfoConverter;
import com.aliyun.messagemgt.dto.sys.SysUserInfoDTO;
import com.aliyun.messagemgt.entities.SysUserInfo;
import com.aliyun.messagemgt.repository.mappers.SysUserInfoMapper;
import com.aliyun.messagemgt.domain.repository.ISysUserInfoService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 系统表-用户信息表 服务实现类
 * </p>
 *
 * @author wugongzi
 * @since 2021-09-18
 */
@Service
public class SysUserInfoServiceImpl implements ISysUserInfoService {

    @Autowired
    private SysUserInfoMapper sysUserInfoMapper;
    @Override
    public List<SysUserInfoDTO> getUserIdByMobile(List<String> mobiles) {
        QueryWrapper<SysUserInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("mobile_phone",mobiles);
        List<SysUserInfo> sysUserInfoList = sysUserInfoMapper.selectList(queryWrapper);
        List<SysUserInfoDTO> sysUserInfoDTOList = SysUserInfoConverter.INSTANCE.sysUserInfoList2sysUserInfoDTOList(sysUserInfoList);
        return sysUserInfoDTOList;
    }

    @Override
    public void batchInsert(List<SysUserInfoDTO> noSyncUserInfoList) {
        List<SysUserInfo> sysUserInfoList = SysUserInfoConverter.INSTANCE.sysUserInfoDTOList2sysUserInfoList(noSyncUserInfoList);
        sysUserInfoMapper.batchInsert(sysUserInfoList);
    }
}
